package com.dqp.cslggroup.UI;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.dqp.cslggroup.R;
import com.dqp.cslggroup.bean.exam;

import java.util.List;

public class ExamAdapter extends BaseAdapter {
    private List<exam> exams;
    private LayoutInflater inflater;
    private ExamAdapter examAdapter;
    private Context context;
    private boolean kao = false;

    public ExamAdapter(List<exam> exams, Context context) {
        this.exams = exams;
        this.inflater = LayoutInflater.from(context);
        this.context = context;
    }

    public ExamAdapter(List<exam> exams, Context context, boolean kao) {
        this.exams = exams;
        this.inflater = LayoutInflater.from(context);
        this.context = context;
        this.kao = kao;
    }

    @Override
    public int getCount() {
        return exams == null ? 0 : exams.size();
    }

    @Override
    public Object getItem(int position) {
        return exams.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        @SuppressLint("ViewHolder") View view = inflater.inflate(R.layout.grade_list, null);
        exam exam = (exam) getItem(position);
        TextView kc = view.findViewById(R.id.text_kc);
        TextView xf = view.findViewById(R.id.text_xf);
        TextView cj = view.findViewById(R.id.text_cj);
        TextView jd = view.findViewById(R.id.text_jd);
        kc.setText(exam.getKcmc());
        xf.setText(exam.getKsmc());
        cj.setText(exam.getKssj());
        jd.setText(exam.getCdmc());
        if (kao) {
            kc.setTextSize(10);
            xf.setTextSize(10);
            cj.setTextSize(10);
            jd.setTextSize(10);
        }
        return view;
    }
}
